cmake_minimum_required(VERSION 3.0.2)
project(cyberarm_controller)

## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  message_generation
)

add_message_files(
  FILES
  pp_msg.msg
  fv_msg.msg
  ft_msg.msg
  ip_msg.msg
  me_msg.msg
  state_msg.msg
  property_msg.msg
  arm_state_msg.msg
)

generate_messages(
  DEPENDENCIES
  std_msgs  # Or other packages containing msgs
)

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
  INCLUDE_DIRS
    include
  CATKIN_DEPENDS
    can_msgs
    roscpp
    message_runtime
)

## 添加外部库路径s
find_library(RA_LIB libra_lib.a PATHS ${CMAKE_SOURCE_DIR}/../../robot_algorithm/build)
include_directories(${CMAKE_SOURCE_DIR}/../../robot_algorithm/include)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
  ${PROJECT_SOURCE_DIR}/devel/include/
  ${CMAKE_CURRENT_SOURCE_DIR}/include
  include
  ${catkin_INCLUDE_DIRS}
)

# all subscriber
add_executable(me_subscriber_node src/subscriber/me_subscriber.cpp)
target_link_libraries(me_subscriber_node ${catkin_LIBRARIES})
add_executable(recvmsg_subscriber_node src/subscriber/recvmsg_subscriber.cpp)
target_link_libraries(recvmsg_subscriber_node ${catkin_LIBRARIES})
add_executable(property_subscriber_node src/subscriber/property_subscriber.cpp)
target_link_libraries(property_subscriber_node ${catkin_LIBRARIES})
add_executable(pp_subscriber_node src/subscriber/pp_subscriber.cpp)
target_link_libraries(pp_subscriber_node ${catkin_LIBRARIES})
add_executable(ip_subscriber_node src/subscriber/ip_subscriber.cpp)
target_link_libraries(ip_subscriber_node ${catkin_LIBRARIES})
add_executable(fv_subscriber_node src/subscriber/fv_subscriber.cpp)
target_link_libraries(fv_subscriber_node ${catkin_LIBRARIES})
add_executable(ft_subscriber_node src/subscriber/ft_subscriber.cpp)
target_link_libraries(ft_subscriber_node ${catkin_LIBRARIES})

# arm init node
add_executable(arm_property_publisher_node src/arm_property_publisher.cpp)
target_link_libraries(arm_property_publisher_node ${catkin_LIBRARIES})
add_executable(arm_state_node src/arm_state.cpp)
target_link_libraries(arm_state_node ${catkin_LIBRARIES})
add_executable(arm_set_zero_node src/arm_set_zero.cpp)
target_link_libraries(arm_set_zero_node ${catkin_LIBRARIES})
add_executable(arm_pos_mode_init_node src/arm_pos_mode_init.cpp)
target_link_libraries(arm_pos_mode_init_node ${catkin_LIBRARIES})

# test node
add_executable(test_plan_node src/test_plan.cpp)
target_link_libraries(test_plan_node move_interface_header ${catkin_LIBRARIES})
target_link_libraries(test_plan_node ${catkin_LIBRARIES})
target_link_libraries(test_plan_node ${RA_LIB})


# # demo
add_executable(demo_teach_move_point_node src/demo_teach_move_point.cpp)
target_link_libraries(demo_teach_move_point_node move_interface_header ${catkin_LIBRARIES})
target_link_libraries(demo_teach_move_point_node ${catkin_LIBRARIES})
target_link_libraries(demo_teach_move_point_node ncurses ${catkin_LIBRARIES})
target_link_libraries(demo_teach_move_point_node ${RA_LIB})

add_library(move_interface_header
    include/move_interface.hpp
    src/function/move.cpp
)
add_dependencies(move_interface_header ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(move_interface_header
  ${catkin_LIBRARIES}
)

add_dependencies(me_subscriber_node ${PROJECT_NAME}_generate_messages_cpp)
add_dependencies(recvmsg_subscriber_node ${PROJECT_NAME}_generate_messages_cpp)
add_dependencies(property_subscriber_node ${PROJECT_NAME}_generate_messages_cpp)
add_dependencies(pp_subscriber_node ${PROJECT_NAME}_generate_messages_cpp)
add_dependencies(ip_subscriber_node ${PROJECT_NAME}_generate_messages_cpp)
add_dependencies(fv_subscriber_node ${PROJECT_NAME}_generate_messages_cpp)
add_dependencies(ft_subscriber_node ${PROJECT_NAME}_generate_messages_cpp)

add_dependencies(arm_property_publisher_node ${PROJECT_NAME}_generate_messages_cpp)
add_dependencies(arm_state_node ${PROJECT_NAME}_generate_messages_cpp)
add_dependencies(arm_set_zero_node ${PROJECT_NAME}_generate_messages_cpp)
add_dependencies(arm_pos_mode_init_node ${PROJECT_NAME}_generate_messages_cpp)

add_dependencies(demo_teach_move_point_node ${PROJECT_NAME}_generate_messages_cpp)
add_dependencies(test_plan_node ${PROJECT_NAME}_generate_messages_cpp)
